package designMode.iteratorPattern;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

/**
 * @author LIBOFEI
 * @ClassName Print
 * @description 打印类
 * @date 2020/6/26 16:40
 * @Version 1.0
 **/
public class Print {

//    MenuIterator pancakeHouseMenu;
//    MenuIterator dinnerHouseMenu;
//    MenuIterator cafeMenu;
    List<MenuIterator> iterators;
    /** *
     * 构造传入所有的菜单
//     * @param pancakeHouseMenu,dinnerHouseMenu
     * @author LIBOFEI
     * @date 16:41 2020/6/26
     * @return
     * @Version  1.0
    **/
//    public Print(MenuIterator pancakeHouseMenu,MenuIterator dinnerHouseMenu,CafeMennu cafeMennu){
//        this.pancakeHouseMenu = pancakeHouseMenu;
//        this.dinnerHouseMenu = dinnerHouseMenu;
//        this.cafeMenu = cafeMennu;
//    }

    public Print(List<MenuIterator> iterators){
        this.iterators = iterators;
    }

    /** *
     * 打印所有的菜单
     * @author LIBOFEI
     * @date 16:42 2020/6/26
     * @return void
     * @Version  1.0
    **/
    public void printAllMenu(){
//        Iterator<MenuItem> pancakeIterator = pancakeHouseMenu.createIterator();
////        Iterator<MenuItem> dinnerIterator = dinnerHouseMenu.createIterator();
////        Iterator<MenuItem> cafeMenu1 = cafeMenu.createIterator();
////        printMenu(pancakeIterator);
////        printMenu(dinnerIterator);
////        printMenu(cafeMenu1);
        Iterator<MenuIterator> iteratorIterator = iterators.iterator();
        while(iteratorIterator.hasNext()){
            printMenu(iteratorIterator.next().createIterator());
        }
    }

    public void printMenu(Iterator<MenuItem> iterator){
        while(iterator.hasNext()){
            MenuItem menuItem = iterator.next();
            System.out.println(menuItem);
        }
    }
}
